home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / amhelios / test_4.cpp < prev    next >
C/C++ Source or Header  |  1999-01-01  |  4KB  |  129 lines

  1. ////////////////////////////////////////////////////////////
  2. //
  3. //  TEST_4.CPP - Ray Casting Test Program
  4. //
  5. //  Version:    1.03A
  6. //
  7. //  History:    94/08/23 - Version 1.00A release.
  8. //              94/12/16 - Version 1.01A release.
  9. //              95/02/05 - Version 1.02A release.
  10. //              95/07/21 - Version 1.02B release.
  11. //              96/02/14 - Version 1.02C release.
  12. //              96/04/01 - Version 1.03A release.
  13. //
  14. //  Compilers:  Microsoft Visual C/C++ Professional V1.5
  15. //              Borland C++ Version 4.5
  16. //
  17. //  Author:     Ian Ashdown, P.Eng.
  18. //              byHeart Software Limited
  19. //              620 Ballantree Road
  20. //              West Vancouver, B.C.
  21. //              Canada V7S 1W3
  22. //              Tel. (604) 922-6148
  23. //              Fax. (604) 987-7621
  24. //
  25. //  Copyright 1994-1996 byHeart Software Limited
  26. //
  27. //  The following source code has been derived from:
  28. //
  29. //    Ashdown, I. 1994. Radiosity: A Programmer's
  30. //    Perspective. New York, NY: John Wiley & Sons.
  31. //
  32. //  It may be freely copied, redistributed, and/or modified
  33. //  for personal use ONLY, as long as the copyright notice
  34. //  is included with all source code files.
  35. //
  36. ////////////////////////////////////////////////////////////
  37.  
  38. // NOTE: _NOT_WIN_APP must be globally defined for this
  39. //       program to be successfully compiled
  40.  
  41. #include <stdio.h>
  42. #include <stdlib.h>
  43. #include <iostream.h>
  44. #include <time.h>
  45. #include "error.h"
  46. #include "parse.h"
  47. #include "ray_cast.h"
  48.  
  49. // Default entity directory path
  50. static char NoEntityDir[] = "";
  51.  
  52. static RayCast Ray;             // Ray casting
  53. static Parse Parser;            // World file parser
  54. static Environ Environment;     // Environment
  55.  
  56. int main( int argc, char **argv )
  57. {
  58.   char *pentdir;        // Entity directory path
  59.   Instance *penv;       // Environment pointer
  60.   Instance *pinst_1;    // Instance pointer
  61.   Instance *pinst_2;    // Instance pointer
  62.   Surface3 *psurf;      // Surface pointer
  63.   Patch3 *ppatch;       // Patch pointer
  64.   Vertex3 *pvert;       // Vertex pointer
  65.   WORD src_id = 1;      // Source patch identifier
  66.   WORD rcv_id;          // Receiving vertex identifier
  67.  
  68.   // Get entity directory path (if any)
  69.   if (argc > 2)
  70.     pentdir = argv[2];
  71.   else
  72.     pentdir = NoEntityDir;
  73.  
  74.   // Parse the environment file
  75.   if (Parser.ParseFile(argv[1], pentdir, &Environment) ==
  76.       FALSE)
  77.     return 1;
  78.  
  79.   // Seed the random number generator
  80.   srand((unsigned) time(NULL));
  81.  
  82.   // Get environment pointer
  83.   pinst_1 = penv = Environment.GetInstPtr();
  84.  
  85.   // Walk the instance list
  86.   while (pinst_1 != NULL)
  87.   {
  88.     // Walk the surface list
  89.     psurf = pinst_1->GetSurfPtr();
  90.     while (psurf != NULL)
  91.     {
  92.       // Walk the patch list
  93.       ppatch = psurf->GetPatchPtr();
  94.       while (ppatch != NULL)
  95.       {
  96.         // Initialize the ray casting object
  97.         Ray.Init(ppatch);
  98.         cout << "Patch " << src_id << endl;
  99.  
  100.         // Walk the instance list
  101.         rcv_id = 1;
  102.         pinst_2 = penv;
  103.         while (pinst_2 != NULL)
  104.         {
  105.           // Walk the vertex list
  106.           pvert = pinst_2->GetVertPtr();
  107.           while (pvert != NULL)
  108.           {
  109.             cout << "  FF(" << rcv_id++ << "," << src_id <<
  110.                 ") = " << Ray.CalcFormFactor(pvert, penv)
  111.                 << endl;
  112.             pvert = pvert->GetNext();
  113.           }
  114.           pinst_2 = pinst_2->GetNext();
  115.         }
  116.         src_id++;
  117.         ppatch = ppatch->GetNext();
  118.       }
  119.       psurf = psurf->GetNext();
  120.     }
  121.     pinst_1 = pinst_1->GetNext();
  122.   }
  123.  
  124.   cout << endl << "Number of rays = " << RC_NumRays;
  125.  
  126.   return 0;
  127. }
  128.  
  129.